	//获取parent数据表个row,渲染界面
	var row = parent.$("#table").jfTable("getRow",parentRowIndex);
$(function(){

	$("#view_id").val(row.id);
	$("#view_userName").val(row.createUserInfo.userName);
	$("#view_inTime").val(formatterDate(row.inTime));
	$("#view_remark").val(row.remark1);
	var assetInPlans = row.assetInPlans;
	
	if(null != assetInPlans && assetInPlans.length > 0){
		for(var i=0;i<assetInPlans.length;i++){
			var row_r = assetType.initAeestType(assetInPlans[i].assetType.name,assetInPlans[i].assetModel.assetModelName,assetInPlans[i].inCount,assetInPlans[i].inCountTruth);
			$("#itemTable").append(row_r);
		}
	}
	
		
});



//渲染数据表格
layui.use('table', function(){
	  var table = layui.table;
	  
	  table.render({
	    elem: '#assetInTruthTable'
	    ,url:'../assetintruth/getAssetInTruthPage.shtml?assetInId='+row.id
	    ,method:'post'
	    ,cols: [[
	      {field:'assetInfoRfidCode', width:110, title: 'rfid', sort: true}
	      ,{field:'assetTypeName', width:60, title: '类型'}
	      ,{field:'assetInfoStatusName', width:50, title: '状态', sort: true}
	      ,{field:'inputTime', width:180, title: '录入时间',templet:'#createTime'}
	    ]]
	    ,page: true
	  });
});



var assetType = {
		
		initAeestType:function(assetInPlanName,assetModelName,assetInPlanNum,assetInPlanTruthNum){
			var div = $("<div>");
			var tr=$("<tr>");
			
			var td1=$("<td>");
			var div1=$("<div style='display:inline-block'>");
			var lable1="<label class='layui-form-label' style='width:80px'>类型</label>";
			var div2=$("<div class='layui-input-inline'style='width:116px;text-align: center'>");
			var select1=$("<input type='text' disabled value='"+assetInPlanName+"' name='assetTypeNum'  class='layui-input'>");
			
			var tdModel=$("<td>");
			var divModel1=$("<div style='display:inline-block'>");
			var lableModel="<label class='layui-form-label' style='width:80px'>型号</label>";
			var divModel2=$("<div class='layui-input-inline'style='width:116px;text-align: center'>");
			var selectModel=$("<input type='text' disabled value='"+assetModelName+"' name='assetModelName'  class='layui-input'>");
			
			
			var td2=$("<td>");
			var div3=$("<div style='display:inline-block'>");
			var lable2="<label class='layui-form-label' style='width:80px'>数量</label>";
			var div4=$("<div class='layui-input-inline' style='width:116px;text-align: center'>");
			var numInput=$("<input type='text' disabled name='assetTypeNum' value='"+assetInPlanNum+"'  class='layui-input'>");
			
			var td3=$("<td>");
			var div5=$("<div style='display:inline-block'>");
			var lable3="<label class='layui-form-label' style='width:100px'>实际数量</label>";
			var div6=$("<div class='layui-input-inline' style='width:116px;text-align: center'>");
			var numInput2=$("<input type='text' disabled name='assetTypeTruthNum' value='"+assetInPlanTruthNum+"' class='layui-input'>");
			
			
			//将input添加到div中
			div2.append(select1);
			
			div1.append(lable1);
			div1.append(div2);
			td1.append(div1);
			
			divModel2.append(selectModel);
			divModel1.append(lableModel);
			divModel1.append(divModel2);
			tdModel.append(divModel1);
			

			div4.append(numInput);
			div3.append(lable2);
			div3.append(div4);
			td2.append(div3);
			
			div6.append(numInput2);
			div5.append(lable3);
			div5.append(div6);
			td3.append(div5);
			
			
			tr.append(td1);
			tr.append(tdModel);
			tr.append(td2);
			tr.append(td3);
			div.append(tr);
			
			return div.html();
			this.div.append(this.tr);
			return this.div;
		}
};


/*layui.use([ 'element', 'form','laydate' ], function() {
	var element = layui.element(), form = layui.form(),laydate = layui.laydate;
	
	form.on('submit(formSubmit)', function(data) {
		console.info(data.field);
		var dataParam = data.field;
		
		var assetTypeSelect = '';
		$("select[name='assetTypeSelect']").each(function(){
			assetTypeSelect = assetTypeSelect + $(this).val()+",";
		});
		if(assetTypeSelect.length > 0){
			assetTypeSelect = assetTypeSelect.substring(0, assetTypeSelect.length-1);
		}
		
		var assetTypeNum = ''
		$("input[name='assetTypeNum']").each(function(){
			assetTypeNum = assetTypeNum + $(this).val()+",";
		});
		if(assetTypeNum.length > 0){
			assetTypeNum = assetTypeNum.substring(0, assetTypeNum.length-1);
		}
		
		dataParam.assetTypeSelect = assetTypeSelect;
		dataParam.assetTypeNum = assetTypeNum;
		console.info(dataParam);
		$.post(rootPath + "/assetin/assetInAdd.shtml", dataParam, function(result) {
			if (!result.status) {
				layer.msg(result.message, {
					icon : 5,
					shift : 6
				});
			} else {
				layer.msg('添加成功', {
					icon : 1
				});
				parent.refreshAsstInList();
			}
		}, "json");
		return false;
	});
	
});


function assetDtnFun(btnObj){
	var btnId = $(btnObj).attr("id");
	var btnArr = btnId.split('_');
	$("#item_tr_"+btnArr[1]).remove();
};

$(function(){
	
	
	//资产详情事件
	$('#addAssetType').click(function() {
		var assetTypeAllJson  = JSON.parse(assetTypeAlls.replace(/'/g,'"'));
		
		var trTotal = $("tr[id*='item_tr_']");
		$("#itemTable").append(assetType.initAeestType((trTotal.length+1),assetTypeAllJson));

		var form = layui.form();//只有执行了这一步，部分表单元素才会自动修饰成功
        form.render();//重新渲染界面上的select
	});
	
	var assetType = {
			
			initAeestType:function(curTrNum,assetTypeAllJson){
				var div = $("<div>");
				var tr=$("<tr>");
				
				var td1=$("<td>");
				var div1=$("<div class='layui-form-item'>");
				var lable1="<label class='layui-form-label'><font color='red'>*</font>类型</label>";
				var div2=$("<div class='layui-input-inline'>");//class='layui-input-inline'
				var select1=$("<select name='assetTypeSelect' required lay-verify='required'>");
				
				
				var td2=$("<td>");
				var div3=$("<div class='layui-form-item'>");
				var lable2="<label class='layui-form-label'><font color='red'>*</font>数量</label>";
				var div4=$("<div class='layui-input-inline'>");
				var numInput=$("<input type='text' name='assetTypeNum' lay-verify='required'  required placeholder='输入个数量吧' autocomplete='off' class='layui-input'>");
				
				var td3=$("<td>");
				//var delBtn = $("<input type='button' value='删除' id='addAssetType' class=''></input>");
				//var delBtn = $("<button class='layui-btn layui-btn-sm layui-btn-normal'>删除</button>");
				//var delBtn = $("<button  class='layui-btn layui-btn-primary layui-btn-sm'>删除</button>");
				var delBtn = $("<input type='button' onclick='assetDtnFun(this)' value='删除'  class='layui-btn layui-btn-primary layui-btn-sm'></input>");
				
				
				//设置trID
				tr.attr("id","item_tr_"+curTrNum);
				
				//拼接原生select
				var selectObj = this.getSelectObj(select1,assetTypeAllJson);
				//将原生select添加到div中
				div2.append(selectObj);
				
				div1.append(lable1);
				div1.append(div2);
				td1.append(div1);
				
				div4.append(numInput);
				div3.append(lable2);
				div3.append(div4);
				td2.append(div3);
				
				delBtn.attr('id','dtn_'+curTrNum);
				td3.append(delBtn);
				
				tr.append(td1);
				tr.append(td2);
				tr.append(td3);
				div.append(tr)
				
				return div.html();
				this.div.attr("id","item_tr_div_"+curTrNum);
				this.div.append(this.tr);
				return this.div;
			},
			getSelectObj:function(select,assetTypeAllJson){
				select.append(this.getSelectOption('','搜索选择'));
				for(var i=0;i<assetTypeAllJson.length;i++){
					var asseType = assetTypeAllJson[i];
					select.append(this.getSelectOption(asseType.id,asseType.name));
				}
				return select;
			},
			
			getSelectOption:function(value,text){
				var option = $("<option>");
				option.attr("value",value);
				option.append(text);
				return option;
			}
	};

});*/
